//    Copyright (C) Kherty.  All rights reserved.
using System.IO;
using System.IO.Packaging;
using System.Xml;

namespace OpenLS.Core.Serialization
{
    public class RelatedReadContext : ReadContext
    {
        private Stream _stream;

        public RelatedReadContext(XmlReader reader, PackagePart part, string namespaceUri, Stream stream,
                                  PackageRelationship relationship)
            : base(reader, part, namespaceUri)
        {
            Relationship = relationship;
            _stream = stream;
        }

        public PackageRelationship Relationship { get; internal set; }

        public override void Dispose()
        {
            base.Dispose();
            Reader.Close();
            _stream.Close();
        }

        public void Reset()
        {
            _stream.Close();
            Reader.Close();
            _stream = Part.GetStream();
            Reader = XmlReader.Create(_stream);// new XmlTextReader(_stream);
        }
    }
}